home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / regicon / code5.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-02-06  |  10.6 KB  |  220 lines

  1. VERSION 5.00
  2. Begin VB.Form frmCode 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Step 0"
  5.    ClientHeight    =   5985
  6.    ClientLeft      =   1965
  7.    ClientTop       =   2355
  8.    ClientWidth     =   8775
  9.    LinkTopic       =   "Form2"
  10.    LockControls    =   -1  'True
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    PaletteMode     =   1  'UseZOrder
  14.    ScaleHeight     =   5985
  15.    ScaleWidth      =   8775
  16.    ShowInTaskbar   =   0   'False
  17.    StartUpPosition =   2  'CenterScreen
  18.    Begin VB.CommandButton cmdNext 
  19.       Caption         =   "&Next >>"
  20.       Height          =   375
  21.       Left            =   6000
  22.       TabIndex        =   4
  23.       Top             =   5400
  24.       Width           =   1215
  25.    End
  26.    Begin VB.TextBox txtDesc 
  27.       Appearance      =   0  'Flat
  28.       BackColor       =   &H00C0C0C0&
  29.       BorderStyle     =   0  'None
  30.       BeginProperty Font 
  31.          Name            =   "MS Sans Serif"
  32.          Size            =   9.75
  33.          Charset         =   0
  34.          Weight          =   400
  35.          Underline       =   0   'False
  36.          Italic          =   0   'False
  37.          Strikethrough   =   0   'False
  38.       EndProperty
  39.       Height          =   1695
  40.       Left            =   120
  41.       MultiLine       =   -1  'True
  42.       TabIndex        =   3
  43.       Text            =   "code5.frx":0000
  44.       Top             =   120
  45.       Width           =   8535
  46.    End
  47.    Begin VB.CommandButton cmdClose 
  48.       Cancel          =   -1  'True
  49.       Caption         =   "&Close"
  50.       Height          =   375
  51.       Left            =   7440
  52.       TabIndex        =   2
  53.       Top             =   5400
  54.       Width           =   1215
  55.    End
  56.    Begin VB.CommandButton cmdBack 
  57.       Caption         =   "<< &Back"
  58.       Height          =   375
  59.       Left            =   4800
  60.       TabIndex        =   1
  61.       Top             =   5400
  62.       Width           =   1215
  63.    End
  64.    Begin VB.TextBox txtCode 
  65.       BeginProperty Font 
  66.          Name            =   "Courier New"
  67.          Size            =   8.25
  68.          Charset         =   0
  69.          Weight          =   400
  70.          Underline       =   0   'False
  71.          Italic          =   0   'False
  72.          Strikethrough   =   0   'False
  73.       EndProperty
  74.       Height          =   3255
  75.       Left            =   120
  76.       Locked          =   -1  'True
  77.       MultiLine       =   -1  'True
  78.       ScrollBars      =   3  'Both
  79.       TabIndex        =   0
  80.       Top             =   1920
  81.       Width           =   8535
  82.    End
  83. Attribute VB_Name = "frmCode"
  84. Attribute VB_GlobalNameSpace = False
  85. Attribute VB_Creatable = False
  86. Attribute VB_PredeclaredId = True
  87. Attribute VB_Exposed = False
  88. Private Sub cmdBack_Click()
  89.     Dim i As Integer
  90.     i = CInt(frmCode.Tag)
  91.     If i > 1 Then
  92.         i = i - 1
  93.         frmCode.Tag = CStr(i)
  94.         cmdNext.Enabled = True
  95.         If i < 2 Then
  96.             cmdBack.Enabled = False
  97.         End If
  98.         ShowCode
  99.     End If
  100. End Sub
  101. Private Sub cmdClose_Click()
  102.     Unload Me
  103. End Sub
  104. Private Sub cmdNext_Click()
  105.     Dim i As Integer
  106.     i = CInt(frmCode.Tag)
  107.     If i <= 4 Then
  108.         i = i + 1
  109.         frmCode.Tag = CStr(i)
  110.         cmdBack.Enabled = True
  111.         If i >= 4 Then
  112.             cmdNext.Enabled = False
  113.         End If
  114.         ShowCode
  115.     End If
  116. End Sub
  117. Private Sub Form_Load()
  118.     frmCode.Icon = Form1.Icon
  119.     frmCode.Tag = "1"
  120.     txtDesc.BackColor = Me.BackColor
  121.     txtCode.FontSize = 9
  122.     cmdBack.Enabled = False
  123.     ShowCode
  124. End Sub
  125. Private Sub ShowCode()
  126.     Dim Code As String
  127.     Dim Desc As String
  128.     Dim inset As String
  129.     inset = Space$(2)
  130.     Select Case frmCode.Tag
  131.         Case "1"
  132.             Me.Caption = "Step-1 Verifying a Key or Item (IsEntry method)"
  133.             Desc = "The IsEntry method can be used to determine whether a Key or Item " & _
  134.             "exists. After specifying the RootKey and Key, IsEntry will return True " & _
  135.             "if the key exists and False if it does not." & vbCrLf & vbCrLf & "If " & _
  136.             "KeyItemName is specified, IsEntry will return True if the Item exists within the " & _
  137.             "key and False if the Item within the key does not exist." & vbCrLf & vbCrLf & _
  138.             "Note: Use the EnumerateEntry method to retrieve the subkeys and items of a key."
  139.             
  140.             Code = vbCrLf & inset & "RegiCon1.RootKey = rkHKEY_LOCAL_MACHINE" & vbCrLf
  141.             Code = Code & inset & "RegiCon1.Key = ""SOFTWARE\Classes\http\shell\open\ddeexec\Application""" & vbCrLf
  142.             Code = Code & inset & "RegiCon1.KeyItemName = """"" & vbCrLf
  143.             Code = Code & inset & "If RegiCon1.IsEntry = False Then" & vbCrLf
  144.             Code = Code & inset & inset & "'no default browser, disable change start page options" & vbCrLf
  145.             Code = Code & inset & inset & "cboStartPages.Enabled = False" & vbCrLf
  146.             Code = Code & inset & inset & "cmdApply.Enabled = False" & vbCrLf
  147.             Code = Code & inset & inset & "cmdReset.Enabled = False" & vbCrLf
  148.             Code = Code & inset & inset & "Exit Sub" & vbCrLf
  149.             Code = Code & inset & "End If"
  150.         Case "2"
  151.             Me.Caption = "Step-2 Retrieving the default value of a Key (GetEntry method)"
  152.             Desc = "To retrieve a value we must specify the RootKey, the Key and " & _
  153.             "the KeyItemName properties. Since the default browser is the key's " & _
  154.             "default entry, we clear KeyItemName." & vbCrLf & vbCrLf & _
  155.             "After invoking GetEntry, KeyItemValue will contain the entry (the default browser " & _
  156.             "in this case)." & vbCrLf & vbCrLf & "Note: KeyItemType will also contain the data type of entry."
  157.             Code = vbCrLf & inset & "RegiCon1.RootKey = rkHKEY_LOCAL_MACHINE" & vbCrLf
  158.             Code = Code & inset & "RegiCon1.Key = ""SOFTWARE\Classes\http\shell\open\ddeexec\Application""" & vbCrLf
  159.             Code = Code & inset & "RegiCon1.KeyItemName = """"" & vbCrLf
  160.             Code = Code & inset & "RegiCon1.GetEntry" & vbCrLf
  161.             Code = Code & inset & "'" & vbCrLf
  162.             Code = Code & inset & "'Display the entry" & vbCrLf
  163.             Code = Code & inset & "lblDefaultBrowser.Caption = RegiCon1.KeyItemValue"
  164.         Case "3"
  165.             Me.Caption = "Step-3 Retrieving an Item (GetEntry method)"
  166.             Desc = "Like most applications, each browser has its own set of registry " & _
  167.             "keys. Therefore, the location for the start page entry depends " & _
  168.             "on the default browser. Again, we use GetEntry to retrieve the desired information " & _
  169.             "after setting the RootKey, Key, and KeyItemName properties." & vbCrLf & vbCrLf & _
  170.             "In this case, after invoking GetEntry, KeyItemValue will contain the start page."
  171.             Code = vbCrLf & inset & "If InStr(1, lblDefaultBrowser.Caption, ""IExplore"", 1) > 0 Then" & vbCrLf
  172.             Code = Code & inset & inset & "RegiCon1.RootKey = rkHKEY_CURRENT_USER" & vbCrLf
  173.             Code = Code & inset & inset & "RegiCon1.Key = ""Software\Microsoft\Internet Explorer\Main""" & vbCrLf
  174.             Code = Code & inset & inset & "RegiCon1.KeyItemName = ""Start Page""" & vbCrLf
  175.             Code = Code & inset & inset & "RegiCon1.GetEntry" & vbCrLf
  176.             Code = Code & inset & inset & "'" & vbCrLf
  177.             Code = Code & inset & inset & "'capture the entry" & vbCrLf
  178.             Code = Code & inset & inset & "DefaultStartPage = RegiCon1.KeyItemValue" & vbCrLf
  179.             Code = Code & inset & "ElseIf InStr(1, lblDefaultBrowser.Caption, ""Netscape"", 1) > 0 Then" & vbCrLf
  180.             Code = Code & inset & inset & "RegiCon1.RootKey = rkHKEY_CURRENT_USER" & vbCrLf
  181.             Code = Code & inset & inset & "RegiCon1.Key = ""Software\Netscape\Netscape Navigator\Main""" & vbCrLf
  182.             Code = Code & inset & inset & "RegiCon1.KeyItemName = ""Home Page""" & vbCrLf
  183.             Code = Code & inset & inset & "RegiCon1.GetEntry" & vbCrLf
  184.             Code = Code & inset & inset & "'" & vbCrLf
  185.             Code = Code & inset & inset & "'capture the entry" & vbCrLf
  186.             Code = Code & inset & inset & "DefaultStartPage = RegiCon1.KeyItemValue" & vbCrLf
  187.             Code = Code & inset & "Else" & vbCrLf
  188.             Code = Code & inset & inset & "'unknown browser, disable change start page options" & vbCrLf
  189.             Code = Code & inset & inset & "cboStartPages.Enabled = False" & vbCrLf
  190.             Code = Code & inset & inset & "cmdApply.Enabled = False" & vbCrLf
  191.             Code = Code & inset & inset & "cmdReset.Enabled = False" & vbCrLf
  192.             Code = Code & inset & inset & "Exit Sub" & vbCrLf
  193.             Code = Code & inset & "End If" & vbCrLf
  194.         
  195.         Case "4"
  196.             Me.Caption = "Step-4 Changing an Item (SetEntry method)"
  197.             Desc = "When changing an entry, one must set the RootKey, Key and KeyItemName properties " & _
  198.             "to specify the location of the Item. The registry supports several data " & _
  199.             "types and the KeyItemType property is used to indicate the desired data type. Finally," & _
  200.             "specify the KeyItemValue property and invoke the SetEntry method."
  201.             Code = vbCrLf & inset & "If InStr(1, lblDefaultBrowser.Caption, ""IExplore"", 1) > 0 Then" & vbCrLf
  202.             Code = Code & inset & inset & "RegiCon1.RootKey = rkHKEY_CURRENT_USER" & vbCrLf
  203.             Code = Code & inset & inset & "RegiCon1.Key = ""Software\Microsoft\Internet Explorer\Main""" & vbCrLf
  204.             Code = Code & inset & inset & "RegiCon1.KeyItemName = ""Start Page""" & vbCrLf
  205.             Code = Code & inset & inset & "RegiCon1.KeyItemType = dtREG_SZ" & vbCrLf
  206.             Code = Code & inset & inset & "RegiCon1.KeyItemValue = NewStartPage" & vbCrLf
  207.             Code = Code & inset & inset & "RegiCon1.SetEntry" & vbCrLf
  208.             Code = Code & inset & "ElseIf InStr(1, lblDefaultBrowser.Caption, ""Netscape"", 1) > 0 Then" & vbCrLf
  209.             Code = Code & inset & inset & "RegiCon1.RootKey = rkHKEY_CURRENT_USER" & vbCrLf
  210.             Code = Code & inset & inset & "RegiCon1.Key = ""Software\Netscape\Netscape Navigator\Main""" & vbCrLf
  211.             Code = Code & inset & inset & "RegiCon1.KeyItemName = ""Home Page""" & vbCrLf
  212.             Code = Code & inset & inset & "RegiCon1.KeyItemType = dtREG_SZ" & vbCrLf
  213.             Code = Code & inset & inset & "RegiCon1.KeyItemValue = NewStartPage" & vbCrLf
  214.             Code = Code & inset & inset & "RegiCon1.SetEntry" & vbCrLf
  215.             Code = Code & inset & "End If" & vbCrLf
  216.     End Select
  217.     txtDesc.Text = Desc
  218.     txtCode.Text = Code
  219. End Sub
  220.